package com.rongc.client.freight.business.carrier.view.fragment;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.rongc.client.core.utils.ActivityUtils;
import com.rongc.client.freight.R;
import com.rongc.client.freight.base.BaseFragment;
import com.rongc.client.freight.base.view.adapter.RecyclerBaseAdapter;
import com.rongc.client.freight.base.view.widget.DividerItemDecoration;
import com.rongc.client.freight.business.carrier.view.activity.ConveyanceSupplyDetailActivity;
import com.rongc.client.freight.business.carrier.view.adapter.RecyclerConveyanceSupplyAdapter;
import com.rongc.client.freight.business.supply.model.SupplyCarBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

/**
 * Created by Bruce on 2016/11/24.
 */
public class ConveyanceSupplyFragment extends BaseFragment {
    @Bind(R.id.recycler)
    RecyclerView mRecyclerView;
    RecyclerConveyanceSupplyAdapter modelAdapter;

    List<SupplyCarBean> datas;

    public static ConveyanceSupplyFragment getInstance(){
        ConveyanceSupplyFragment fragment = new ConveyanceSupplyFragment();
        Bundle bdl = new Bundle();
//        bdl.putString("orderType", orderType);
        fragment.setArguments(bdl);
        return fragment;
    }


    public void setDatas(List<SupplyCarBean> datas){
        this.datas = datas;
    }


    @Override
    public void initData() {
    }

    @Override
    public void initListener() {

    }


    @Override
    public void initView() {
        datas = new ArrayList<>();

        modelAdapter = new RecyclerConveyanceSupplyAdapter(getActivity(),datas);
        datas.add(new SupplyCarBean());
        datas.add(new SupplyCarBean());
        datas.add(new SupplyCarBean());
        datas.add(new SupplyCarBean());
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false));
        mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
        mRecyclerView.setAdapter(modelAdapter);
        modelAdapter.setOnItemClickListener(new RecyclerBaseAdapter.OnItemClickListener<SupplyCarBean>() {
            @Override
            public void onItemClick(View view, int position, SupplyCarBean data) {
                ActivityUtils.startActivity(getActivity(),ConveyanceSupplyDetailActivity.class);
            }
        });

    }


    @Override
    public int getLayoutId() {
        return R.layout.universal_recycler_2;
    }
}
